<?php
// 这个文件是创建红包的
require_once 'AopSdk.php';
require_once 'function.inc.php';
require_once 'config.php';
require_once 'MysqliDb.php';

$db = new MysqliDb ($configDb);
$acount =$db
	->where ('status', 1)
 	->getOne('ali_number');


$aop = new AopClient ();
$aop->gatewayUrl = $config['gatewayUrl'];
$aop->appId = $acount['app_id'];
$aop->rsaPrivateKey = $acount['merchant_private_key'];
$aop->alipayrsaPublicKey=$acount['alipay_public_key'];
$aop->apiVersion = '1.0';
$aop->signType = $config['sign_type'];
$aop->postCharset='utf-8';
$aop->format='json';
$request = new AlipayOpenPublicTemplateMessageGetRequest  ();
$request->setBizContent("{" .
   "\"template_id\":\"".$_POST['template_id']."\"" .
"  }");
$result = $aop->execute ( $request); 
writeLog ( "result: " . var_export ( $result, true ) );
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
$arr=object_array($result->$responseNode);
echo json_encode($arr);
if(!empty($resultCode)&&$resultCode == 10000){
	var_dump($result->$responseNode->msg_template_id);
}
